package com.mibus.mibusmobile;

import android.os.AsyncTask;

import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.client.entity.UrlEncodedFormEntity;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.message.BasicNameValuePair;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class Logout extends AsyncTask<String,Integer,String>{
    protected String doInBackground(String... hash_session) {
        HttpClient httpclient = new DefaultHttpClient();
        HttpPost httppost = new HttpPost("http://mibus.eia.edu.co/tablet/logout");
        String result="" ;
        try {
            List<NameValuePair> nameValuePairs=new ArrayList<NameValuePair>();
            nameValuePairs.add(new BasicNameValuePair("hash_session", hash_session[0]));

            httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
            HttpResponse response = httpclient.execute(httppost);
            HttpEntity entity = response.getEntity();
            result = JSONParser.inputStreamToString(entity.getContent()).toString();
            nameValuePairs.clear();

        } catch (ClientProtocolException e) {
        } catch (IOException e) {
        }
        return result;
    }
}
